package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.News;
import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.query.NewsQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.StrategyQueryObject;
import cn.wolfcode.trip.base.query.TravelQueryObject;
import cn.wolfcode.trip.base.service.INewsService;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.service.ITravelService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("advancedQueries")
public class advancedQueryController {
    @Autowired
    private ITravelService travelService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private INewsService newsService;

    @GetMapping
    public Map<Object,Object> advancedQuery(String keyWord){
        List<Travel> travels = travelService.selectAll(keyWord);
        List<Strategy> strategies = strategyService.selectAll(keyWord);
        List<News> news = newsService.selectAllByKeyWord(keyWord);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("travels",travels);
        map.put("strategies",strategies);
        map.put("news",news);
        return map;
    }
}
